/**
 * 
 */
package com.vector.ding.commons;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import com.vector.ding.context.WebContext;

/**
 * 常量信息类
 * @author vector
 *
 */
public final class Constant {
	
	/**
	 * no way to instance
	 */
	private Constant() {
		
	}
	
	// 默认编码格式
	public static final String DEFAULT_ENCODEING = "UTF-8";
	
	// 前段返回结果（JSONObject）相关key和value值
	public static final String 	RESULT_SUCCESS_KEY 	= "success";
	public static final Boolean RESULT_SUCCESS 		= Boolean.TRUE;
	public static final Boolean RESULT_FAILURE 		= Boolean.FALSE;
	public static final String 	RESULT_CONTENT_KEY 	= "content";
	public static final String 	RESULT_ERROR_KEY 	= "error";
	
	// 登录的url
	public static final String LOGIN_URL = "login.do";
	
	// 密码
	public static final String HIDDEN_PWD = "***";
	public static final String DEFAULT_PWD = "123";
	
	// 表格编辑状态标记
	public static final String RECORD_ADD 		= "add";
	public static final String RECORD_UPDATE 	= "update";
	public static final String RECORD_DELETE 	= "remove";
	
	// 表格相关属性
	public static final int GRID_PAGE_START = 0;
	public static final int GRID_PAGE_SIZE = 20;
	
	public static final int SUGECT_NUM = 5;
	
	// 性别Map
	public static final Map<String, String> SEX_MAP = new HashMap<String, String>(){

		private static final long serialVersionUID = 1L;
		
		// 初始化Map的值
		{
			put("男", "1");
			put("女", "0");
		}
		
	};
	
	public class DaoOperation {
		public static final int UPDATE_FAILURE = -1;
	}
	
	// 应用的根目录
	public static final String APP_PATH = WebContext.getAppRootPath();
	
	// 文件上传常量信息
	public static class Upload {
		
		public static final String TEMP_PATH = APP_PATH + File.separator + "upload"
				+ File.separator + "temp/";
		// 到WEB-INF/class
		private static final String STORE_PATH = APP_PATH + File.separator + "upload"
				+ File.separator + "store/";
		/*Thread.currentThread()
				.getContextClassLoader().getResource("/").getPath()
				+ "upload";*/
		
		public static final String BASE_INF_PATH = STORE_PATH + "/baseinfo/";
		public static final String BIZ_INF_PATH = STORE_PATH + "/bizinfo/";
		
		{
			File tempFolder = new File(TEMP_PATH);
			if (!tempFolder.exists())
				tempFolder.mkdirs();
			
			File storeFolder = new File(STORE_PATH);
			if (!storeFolder.exists())
				storeFolder.mkdirs();
		}
	}
}
